package com.qijian.maindata.domain.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.qijian.common.annotation.Excel;
import com.qijian.maindata.domain.ProcessOrder;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * 工序工单对象
 *
 * @author qijian
 * @date 2021-10-09
 */

@EqualsAndHashCode(callSuper = true)
@Data
@ToString
public class ProcessOrderVo extends ProcessOrder {

    @Excel(name = "项目编号", sort = 6)
    private String projectNo;
    @Excel(name = "产品名称", sort = 8)
    private String projectName;
    @Excel(name = "机台号", sort = 7)
    private String machineNo;
//    @Excel(name = "工单管理人", sort = 11)
//    private String nickName;
//    @Excel(name = "工单管理人所在车间", sort = 5)
//    private String deptName;

    private BigDecimal itemWeight;

    private String planSystem;
    private String planCode;
    private String itemCode;
    private String drawingNo;
    private String partNo;

    private String processTypeName;

    private BigDecimal sumUserWorkCost;
    private BigDecimal bidAmount;
    private Long itemDetailId;

    /**
     * 开发件最大超出百分比
     * 取值来源 sys_config  key = developItemOverRate
     */
    @ApiModelProperty(value = "开发件最大超出百分比")
    private int developItemOverRate;

    @TableField(exist = false)
    @JsonIgnore
    @Excel(name = "日期", sort = 2)
    @ApiModelProperty(value = "excel导出日期")
    private String workStartEndTime;

    public String getWorkStartEndTime() {
        if (this.getWorkStartTime() == null || this.getWorkEndTime() == null) return null;
        SimpleDateFormat fm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return fm.format(this.getWorkStartTime()) + " 至 " + fm.format(this.getWorkEndTime());
    }

    @JsonIgnore
    @TableField(exist = false)
    @Excel(name = "创建时间", dateFormat = "yyyy-MM-dd HH:mm:ss", sort = 16)
    private Date excelCreateTime;

    private Integer approveStatus;

    // 异常label
    public String exceptionLabel;

    // 异常Id
    @JsonSerialize(using = ToStringSerializer.class)
    public Long exceptionId;

    public String managerName;

    // 验收时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    public Date checkTime;

    public Date getExcelCreateTime() {
        return this.getCreateTime();
    }

    // 多个开工令时 开工令列表
    private List<Long> projectIds;

    private String projectManager;

    //工序对应的工艺文件数量
    private Integer processFileCnt;
}
